﻿using System;
using System.Web.UI;

namespace Evolution.UI.WebParts
{
    [Serializable]
    public class ApplicationAssertion : BaseKeyValueAssertion
    {
        #region Properties

        public override string Caption
        {
            get { return "Application variable"; }
        }

        #endregion

        #region Methods

        public override void CreateInterface(ControlCollectionBuilder builder, PageActionEditor editor, int index)
        {
            this.InternalCreateInterface("AV", builder, editor, index);
        }

        public override string GetDescription()
        {
            return this.InternalGetDescription("Application variable");
        }

        public override void SyncChanges(PageActionEditor editor, int index)
        {
            this.InternalSyncChanges("AV", editor, index);
        }

        public override void ApplyChanges(PageActionEditor editor, int index)
        {
            this.InternalApplyChanges("AV", editor, index);
        }

        public override bool Evaluate(Page page, PageActionWebPart part)
        {
            string value = (string)page.Application[this.Key];
            if (value == null)
                value = String.Empty;

            return this.InternalEvaluate(value, page, part);
        }

        #endregion
    }
}
